#!/bin/bash

# 打印logo和描述信息
logo=$(cat <<'EOF'
  _____ _                         _   _             _
 / ____| |                   /\  | | | |           | |
| (___ | | _____      __    /  \ | |_| |_ __ _  ___| | __
 \___ \| |/ _ \ \ /\ / /   / /\ \| __| __/ _` |/ __| |/ /
 ____) | | (_) \ V  V /   / ____ \ |_| || (_| | (__|   <
|_____/|_|\___/ \_/\_/   /_/    \_\__|\__\__,_|\___|_|\_\
EOF
)
echo -e "$logo"
echo -e "\033[1;32;40m[*] Slow-rate attacks are a type of cybersecurity attack against target systems, which involve continuously sending low-frequency requests to gradually occupy its resources or network bandwidth, ultimately leading to service unavailability or a decline in system performance.\033[1;37;40m"

# Define file dictionary
declare -A files
files=(
      ["1"]="ddos/Slow_Attack/Slow_Read_attack.py"
      ["2"]="ddos/Slow_Attack/Slowloris_attack.py"
      ["3"]="ddos/Slow_Attack/Slow_POST_attack.py"
      ["4"]="ddos/Slow_Attack/Slow_GET_attack.py"
      ["5"]="ddos/Slow_Attack/Slow_DNS_attack.py"
      ["6"]="ddos/Slow_Attack/slow_write_attack.py"
      ["7"]="ddos/Slow_Attack/Slow_SSL_attack.py"
)

# Create a menu using whiptail
while true; do
      choice=$(whiptail --title "Slow-rate Attack Types" --menu "Slow-rate attacks are a type of cybersecurity attack against target systems, which involve continuously sending low-frequency requests to gradually occupy its resources or network bandwidth, ultimately leading to service unavailability or a decline in system performance.\n\nPlease select an attack mode:" 35 78 20 \
      "1" "Slow-read attack" \
      "2" "Slowloris attack" \
      "3" "Slow-POST attack" \
      "4" "Slow-GET attack" \
      "5" "Slow-DNS attack" \
      "6" "Slow-write attack" \
      "7" "Slow-SSL attack" \
      "0" "Back" \
      3>&1 1>&2 2>&3)

      if [[ $? -eq 0 ]]; then
          if [[ "$choice" == "0" ]]; then
              echo "Operation cancelled."
              break
          else
              python3 "${files[$choice]}"
              break
          fi
      else
          echo "Operation cancelled."
          break
      fi
done
